package com.u3k.mid;

import android.content.Context;
import com.u3k.app.mid.utils.statistics.StatisticsManager;
import java.io.File;
import java.io.FileOutputStream;

final class ar implements Runnable {
    final /* synthetic */ Context a;
    final /* synthetic */ String b;

    ar(Context context, String str) {
        this.a = context;
        this.b = str;
    }

    public void run() {
        FileOutputStream fileOutputStream;
        Exception e;
        Throwable th;
        FileOutputStream fileOutputStream2 = null;
        boolean z = true;
        try {
            File file = new File(this.a.getExternalFilesDir("") + File.separator);
            if (!file.exists()) {
                z = file.mkdirs();
            }
            if (z) {
                File file2 = new File(this.a.getExternalFilesDir("") + File.separator + "sub_imei" + ".txt");
                if (file2.exists()) {
                    file2.delete();
                }
                file2.createNewFile();
                fileOutputStream = new FileOutputStream(file2);
                try {
                    fileOutputStream.write(this.b.getBytes("utf-8"));
                } catch (Exception e2) {
                    e = e2;
                    try {
                        LogUtils.a("error", e);
                        StatisticsManager.getInstance().logException(this.a, e);
                        if (fileOutputStream != null) {
                            try {
                                fileOutputStream.close();
                            } catch (Exception e3) {
                                LogUtils.a("error", e3);
                                StatisticsManager.getInstance().logException(this.a, e3);
                                return;
                            }
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        fileOutputStream2 = fileOutputStream;
                        fileOutputStream = fileOutputStream2;
                        if (fileOutputStream != null) {
                            try {
                                fileOutputStream.close();
                            } catch (Exception e4) {
                                LogUtils.a("error", e4);
                                StatisticsManager.getInstance().logException(this.a, e4);
                            }
                        }
                        throw th;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    if (fileOutputStream != null) {
                        fileOutputStream.close();
                    }
                    throw th;
                }
            }
            fileOutputStream = null;
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.close();
                } catch (Exception e32) {
                    LogUtils.a("error", e32);
                    StatisticsManager.getInstance().logException(this.a, e32);
                }
            }
        } catch (Exception e5) {
            e32 = e5;
            fileOutputStream = null;
            LogUtils.a("error", e32);
            StatisticsManager.getInstance().logException(this.a, e32);
            if (fileOutputStream != null) {
                fileOutputStream.close();
            }
        } catch (Throwable th4) {
            th = th4;
            fileOutputStream = fileOutputStream2;
            if (fileOutputStream != null) {
                fileOutputStream.close();
            }
            throw th;
        }
    }
}
